package com.example.demo.service;

import com.example.demo.entity.inventory;
import com.example.demo.mapper.inventorymapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class inventoryservice implements inventoryserviceInter {

    @Autowired
    inventorymapper inventorydao;

    @Override
    public int updatenum(inventory i) {
        return inventorydao.updatenum(i);
    }

    @Override
    public int insertcommodity(inventory i) {
        return inventorydao.insertcommodity(i);
    }

    public PageInfo<inventory> display(Integer pagenum, Integer pagesize) {
        PageHelper.startPage(pagenum, pagesize);
        List<inventory> inv = inventorydao.display();
        PageInfo<inventory> pageinfo = new PageInfo<>(inv);

        return  pageinfo;
    }

    public List<inventory> search(inventory i) {
        return inventorydao.search(i);
    }
    public int delete(inventory i) {
        return inventorydao.delete(i);
    }
    public int update(inventory i) {
        return inventorydao.update(i);
    }
    public int minusnum(inventory i) {
        return inventorydao.minusnum(i);
    }
}
